
nums=[1,2,3]

def dfs(nums,depth,path,ans,nums_len,state):
    if depth==nums_len:
        print(path)
        if path not in ans:
            ans.append(path[:])
            # ans.add(path[:])
        return None
    for i in range(nums_len):
        if state[i]==False:
            path.append(nums[i])
            print("nums[i]:",nums[i])
            state[i]=True
            dfs(nums,depth+1,path,ans,nums_len,state)
            path.pop()
            state[i]=False

def permuteUnique(nums):
    nums_len=len(nums)
    path=[]
    ans=[]
    # ans=set()
    state=[False for _ in range(nums_len)]
    dfs(nums,0,path,ans,nums_len,state)
    print("ans:",ans)

permuteUnique(nums)